<template>
    <div>
        <el-tabs v-model="activeName">
            <el-tab-pane label="实践课" name="stu">
                <el-card>
                    <h1>导出实践课问卷结果</h1>
                    <div class="link_stu">
                        <el-link @click="dowloadShi" type="primary">问卷结果下载</el-link>
                    </div>
                    <div class="download_stu">
                        <span class="demonstration">*导出之前先选择期数</span>
                        <el-select v-model="schoolId_c" placeholder="请选择期数">
                            <el-option
                              v-for="(item,index) in options_stu"
                              :key="index"
                              :label="item.cg_periods"
                              :value="item.school_id">
                            </el-option>
                        </el-select>
                        
                    </div>
                </el-card>
            </el-tab-pane>
            <el-tab-pane label="理论课" name="tec">
                <el-card>
                    <h1>导出理论课问卷结果</h1>
                    <div class="link_stu">
                        <el-link @click="dowloadLi" type="primary">问卷结果下载</el-link>
                    </div>
                    <div class="download_stu">
                        <!-- <el-link :href="temp_course" type="primary">导入课表模板下载</el-link> -->
                        <span class="demonstration">*导出之前先选择期数</span>
                        <el-select v-model="schoolId_c" placeholder="请选择期数">
                            <el-option
                              v-for="(item,index) in options_stu"
                              :key="index"
                              :label="item.cg_periods"
                              :value="item.school_id">
                            </el-option>
                        </el-select>
                        
                    </div>
                </el-card>
            </el-tab-pane>
            <el-tab-pane label="调查问卷" name="course">
                <el-card>
                    <h1>导出调查问卷结果</h1>
                    <div class="link_stu">
                        <el-link @click="dowloadQue" type="primary">问卷结果下载</el-link>
                    </div>
                    <div class="download_stu">
                        <!-- <el-link :href="temp_course" type="primary">导入课表模板下载</el-link> -->
                        <span class="demonstration">*导出之前先选择期数</span>
                        
                        <el-select v-model="schoolId_c" placeholder="请选择期数">
                            <el-option
                              v-for="(item,index) in options_stu"
                              :key="index"
                              :label="item.cg_periods"
                              :value="item.school_id"
                              >
                            </el-option>
                        </el-select>
                        
                    </div>
                </el-card>
            </el-tab-pane>
        </el-tabs>
    </div>
</template>

<script>
    import {SERVER_BASE} from "@/api/config";
    import fileImport from '@/api/fileImport';
    import axios from 'axios'

    export default {
        name: "infoImport",
        data() {
            return {
                activeName: 'stu',
                value1: 'studentInfo',
                showDownloadLink:'',
                showDemo: false,
                dialogVisible:false,
                demoUrl:"",
                InfoDownloadLink: '',
                // temp_stu: SERVER_BASE + "/download?"+"course_type=1" + "&school_id=" + this.schoolId_c ,
                // temp_tea: SERVER_BASE + "/download?"+"course_type=2" + "&school_id=" + this.schoolId_c,
                // temp_course: SERVER_BASE + "/download?"+"course_type=3" + "&school_id=" + this.schoolId_c,
                schoolId: '',   // 上传学生信息期数ID
                schoolId_c: '', // 上传课程期数id区分一下
                options_stu: []
            }
        },
        methods: {
            // 获取期数信息
            getAllSchool() {
                let that=this;
                fileImport.getALLSchool().then(function (resp) {
                    if (resp.data.code == '200') {
                        that.options_stu = resp.data.data.list
                        console.log(that.options_stu)
                        console.log(that.options_stu[1])
                    } else {
                        that.$message.warning("期数获取失败!")
                    }
                })
            },
            dowloadShi(){
                console.log(this.schoolId_c)
                location.replace(SERVER_BASE + "/download?"+"course_type=1" + "&school_id=" + this.schoolId_c)

            },
            dowloadLi(){
                console.log(this.schoolId_c)
                location.replace(SERVER_BASE + "/download?"+"course_type=2" + "&school_id=" + this.schoolId_c)


            },
            dowloadQue(){console.log(this.schoolId_c)
                location.replace(SERVER_BASE + "/download?"+"course_type=3" + "&school_id=" + this.schoolId_c)


},
        },
        mounted() {
            this.loginControl();  //登录控制
            this.getAllSchool(); //加载页面时，获取期数信息
        }
    }
</script>

<style scoped>
.download_stu {
    width: 50%;
}
.link_stu {
    position: absolute;
    right: 120px;
}
.demonstration {
    color: red;
}
</style>
<style>
    .upload-demo {
        margin-top: 15px;
    }
</style>